package com.kitty.game.pet.handler;

import com.kitty.game.pet.model.Pet;
import com.kitty.game.role.model.Role;
import com.kitty.game.equip.model.RoleEquip;
import com.kitty.game.config.PetSet;
import com.kitty.common.utils.SpringUtils;
import com.kitty.game.equip.message.RespOperateResult;
import com.kitty.game.equip.service.EquipService;
import com.kitty.game.pet.service.PetService;
import com.kitty.mina.message.MessagePusher;
import com.kitty.game.attribute.AttrService;
import com.kitty.game.fight.service.CountService;
import com.kitty.game.role.service.RoleService;
import org.springframework.stereotype.Component;

/**喂养宠物实现类*/
@Component
public abstract class FeedPetHandler {

    protected PetService petService = SpringUtils.getBean(PetService.class);
    protected EquipService equipService = SpringUtils.getBean(EquipService.class);
    protected AttrService attrService = SpringUtils.getBean(AttrService.class);
    protected RoleService roleService = SpringUtils.getBean(RoleService.class);
    protected CountService countService = SpringUtils.getBean(CountService.class);
    /**野生*/
    static final byte WILD =1;
    /**宝宝*/
    static final byte BABY =2;
    /**变异*/
    protected static final byte VARIATION =3;
    /**神兽*/
    protected static final byte EPIC =4;

    static final String  ERROR_PET_TYPE="#Y{0}#n宠物类型错误，无法进行此操作。";
    static final String  ERROR_PETSET="#Y{0}#n宠物配置未找到，无法进行此操作。";

    public abstract String acceptFeed(Pet pet, Role role, RoleEquip roleEquip);


    /**不等于野生*/
    protected boolean isRightType(byte petType){
        return petType == WILD;
    }

    void pushOperTypeResult(Role role,boolean success){
        RespOperateResult operateResult = new RespOperateResult();
        operateResult.setSuccess(success);
        operateResult.setType("equip_upgrade");
        MessagePusher.pushMessage(role, operateResult);
    }

    PetSet getPetSetByName(String name){
        return petService.getPetByName(name);
    }
}
